import random


def OutputValues():
    for i in range(10):
        print('[',end='')
        for j in range(10):
            print(ArrayData[i][j],end=' ')
        print(']')

def BinarySearch(SearchArray,Lower,Upper,SearchValue):
    if Upper>=Lower:
        Mid=(Lower+Upper)//2
        if SearchArray[0][Mid]==SearchValue:
            return Mid
        else:
            if SearchArray[0][Mid]>SearchValue:
                return BinarySearch(SearchArray,Lower,Mid-1,SearchValue)
            else:
                return BinarySearch(SearchArray, Mid+1, Upper, SearchValue)
    return -1


if __name__ == '__main__':
    ArrayData=[[random.randint(1,100) for i in range(10)] for i in range(10)]
    ArrayLength=10
    OutputValues()
    for X in range(ArrayLength):
        for Y in range(ArrayLength-1):
            for Z in range(ArrayLength-Y-1):
                if ArrayData[X][Z]>ArrayData[X][Z+1]:
                    TempValue=ArrayData[X][Z]
                    ArrayData[X][Z]=ArrayData[X][Z+1]
                    ArrayData[X][Z+1]=TempValue
    print("###########")

    OutputValues()
    value1=ArrayData[0][random.randint(0,9)]
    state=random.randint(1,2)
    if state==1:
        value2 = random.randint(101, 999)
    else:
        value2 = random.randint(-100, 1)
    print('value randomly selected is',value1,' index of this value is',BinarySearch(ArrayData,0,9,value1))
    print('value randomly selected is',value2,' index of this value is',BinarySearch(ArrayData,0,9,value2))

